from gremlin_python import statics
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.structure.graph import Graph
from gremlin_python.process.traversal import T
from gremlin_python.process.traversal import Order
from gremlin_python.process.traversal import Cardinality
from gremlin_python.process.traversal import Column
from gremlin_python.process.traversal import Direction
from gremlin_python.process.traversal import Operator
from gremlin_python.process.traversal import P
from gremlin_python.process.traversal import TextP
from gremlin_python.process.traversal import Pop
from gremlin_python.process.traversal import Scope
from gremlin_python.process.traversal import Barrier
from gremlin_python.process.traversal import Bindings
from gremlin_python.process.traversal import WithOptions


def from_text_contain(graph,string,property_name="code"):
    g = graph
    if not isinstance(string,str):
        try:
            string = str(string)
        except:
            print("请输入字符串")
            return None

    if property_name in["code","ast","lineo"]:
            v_need = g.V().has(property_name,TextP.containing(string)).toList()
    else:
        print("指定类型有问题,将自动切换到按源代码搜索模式")
        try:
            v_need = g.V().has("code",TextP.containing(string)).toList()
        except:
            return None
    return v_need
